
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>合同管理</title>
    {include file="include/top"}
</head>
<body>

<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-form layui-card-header layuiadmin-card-header-auto">
            <div class="layui-inline">
                <label class="layui-form-label">客户姓名</label>
                <div class="layui-input-inline">
                    <input type="text" name="fullname" value="" placeholder="支持模糊搜索" autocomplete="off" class="layui-input">
                </div>
            </div>

            <div class="layui-inline">
                <button class="layui-btn layuiadmin-btn-list" lay-submit lay-filter="LAY-app-contlist-search">
                    <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
                </button>
            </div>
        </div>
        <div class="layui-card-header layuiadmin-card-header-auto">
            <button type="button" class="layui-btn" id="test-upload-type1" data-imgid="adduser"><i class="layui-icon"></i>添加合同</button>
        </div>
        <table class="layui-table" lay-data="{height:0, url:'/adminauth/userlist', page:true, id:'idTest' ,cellMinWidth: 80}" lay-filter="demo">
            <thead>
            <tr>
                <th lay-data="{type:'checkbox'}"></th>
                <th lay-data="{field:'id'}">表单号</th>
                <th lay-data="{field:'username'}">制表日期</th>
                <th lay-data="{field:'fullname'}">客户</th>
                <th lay-data="{field:'phone'}">客户行业</th>
                <th lay-data="{field:'pathid2'}">合同名称</th>
                <th lay-data="{field:'pathid'}">助记码</th>
                <th lay-data="{align:'center', toolbar: '#barDemo',width:70}"></th>
            </tr>
            </thead>
        </table>
        <script type="text/html" id="barDemo">
            <a class="layui-btn layui-btn-xs layui-btn-normal" lay-event="more">操作</i></a>
        </script>
    </div>
</div>
{include file="include/js"}
<script>
    var pathid=0;
    layui.config({
        base: '/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'contlist', 'table', 'dropdown'], function(){
        var table = layui.table;
        var $ = layui.$;
        var form = layui.form;
        var pathid=0;
        var id=0;
        var dropdown = layui.dropdown
        var field
        //监听搜索
        form.on('submit(LAY-app-contlist-search)', function(data){
            field = data.field;
            //执行重载
            table.reload('idTest', {
                where: field,page:{curr:1}
            });
        });
        $('.layui-btn.layuiadmin-btn-tags').on('click', function(){
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });
        $("#test-upload-type1").click(function () {

        });
        function add(){
            layer.open({
                type: 2
                ,title: '添加用户'
                ,content: 'adduser'
                ,btn: ['确定', '取消']
                ,area: ['100%', '80%']
                ,yes: function(index, layero){
                    layer.confirm('是否确定添加?', {icon: 3, title:'提示'}, function(index){
                        //do something
                        var $data={}
                        var othis = layero.find('iframe').contents().find("#layuiadmin-app-form-tags");
                        $data.username = othis.find('input[name="username"]').val()
                        $data.fullname = othis.find('input[name="fullname"]').val()
                        $data.pathid = othis.find('input[name="pathid"]').val()
                        $data.pathid2 = othis.find('input[name="pathid2"]').val()
                        $data.password = othis.find('input[name="password"]').val()
                        $.post("adduserpost",$data,function (re) {
                            layer.msg(re.msg,function (){
                                if(res.code == 0){
                                    table.reload('idTest', {
                                        where: field
                                    });
                                }
                            });
                        },'json');
                        layer.close(index);
                    });
                }
            });
        }
        //监听工具条
        table.on('tool(demo)', function(obj){
            var data = obj.data;
            if(obj.event === 'more'){
                //更多下拉菜单
                var thatData = data
                dropdown.render({
                    elem: that
                    , show: true //外部事件触发即显示
                    , data: [{
                        title: '详情'
                        , id: 'edituser'
                    }, {
                        title: '跟进'
                        , id: 'step'
                    }, {
                        title: '删除'
                        , id: 'del'
                    }]
                    , click: function (data, othis) {
                        //根据 id 做出不同操作
                        if (data.id === 'del') {
                            layer.confirm('是否确定删除?', function (index) {
                                obj.del();
                                id = thatData.id
                                delUser()
                                layer.close(index);
                            });
                        } else if (data.id == 'step') {
                            id = thatData.id
                            log()
                            //跟进

                        } else if (data.id == 'edituser') {
                            //编辑客户
                            id = thatData.id;
                            adduser()
                        }
                    }
                    , align: 'right' //右对齐弹出（v2.6.8 新增）
                    , style: 'box-shadow: 1px 1px 10px rgb(0 0 0 / 12%);' //设置额外样式
                });
            }


        });
    });
</script>

</body>
</html>
